// musicom.cpp : main project file.

#include "stdafx.h"
#include "Form1.h"

using namespace musicom;

[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
	// Enabling Windows XP visual effects before any controls are created
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 

	// Create the main window and run it
	Application::Run(gcnew Form1());
	return 0;
}

void Form1::OnButtonClick(Object^ sender, EventArgs^ e)
{
	// Disabling the button
	Form1::button1->Enabled = false;

	// Parsing imputs
	Int32 device = Convert::ToInt32(textBox1->Text);
	Int32 channel = Convert::ToInt32(textBox2->Text);
	Int32 note = Convert::ToInt32(textBox3->Text);
	Int32 volume = Convert::ToInt32(textBox4->Text);
	Int32 status = 144;
	if (comboBox1->SelectedText == gcnew String("OFF")){status = 128;}
	if (comboBox1->SelectedText == gcnew String("PC")){status = 192;}

	// Creating message and sending it
	libmusico::Message^ msg = gcnew libmusico::Message(channel, status, note, volume);
	command->addMessage("msg", msg);
	command->send(device);

	// Enabling the button
	Form1::button1->Enabled = true;
}
